/*
 * RoboEye - Web client for www.newocr.com that allows you
 * to recognize an image captured by the camera.
 *
 * Copyright (C) Oxygen Development, 2011
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

package com.devoxy.roboeye.ui.activity.task_list;

import android.database.Cursor;
import android.view.View;
import com.devoxy.roboeye.R;
import com.devoxy.roboeye.core.provider.Task;
import com.devoxy.roboeye.ui.adapter.AdapterRule;

/**
 * Created by Oxygen Development.
 * Author: Dmitriy Tarasov (dm.vl.tarasov@gmail.com)
 * Date: 03.07.11
 * Time: 0:37
 */
public class TaskStateRule implements AdapterRule {
    @Override
    public void applyRule(View view, Cursor cursor, String[] from, int[] to) {
        View progress = view.findViewById(R.id.progress);
        View finished = view.findViewById(R.id.finished);

        if (cursor.getInt(cursor.getColumnIndex(Task.STARTED)) == 1) { // task in progress
            progress.setVisibility(View.VISIBLE);
            finished.setVisibility(View.GONE);
        } else if (cursor.getInt(cursor.getColumnIndex(Task.FINISHED)) == 1) { // task is finished
            progress.setVisibility(View.GONE);
            finished.setVisibility(View.VISIBLE);
        } else { //task wait in queue
            progress.setVisibility(View.GONE);
            finished.setVisibility(View.GONE);
        }
    }
}
